<%@page import="com.dc.entity.Users"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!doctype html>
<html lang="ch">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="左右结构项目，属于大人员的社交工具">
<meta name="keywords" content="左右结构项目 社交 占座 ">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<title>校园订餐系统</title>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script>
	$(function() {
		$(".meun-item").click(function() {
			$(".meun-item").removeClass("meun-item-active");
			$(this).addClass("meun-item-active");
			var itmeObj = $(".meun-item").find("img");
			itmeObj.each(function() {
				var items = $(this).attr("src");
				items = items.replace("_grey.png", ".png");
				items = items.replace(".png", "_grey.png")
				$(this).attr("src", items);
			});
			var attrObj = $(this).find("img").attr("src");
			;
			attrObj = attrObj.replace("_grey.png", ".png");
			$(this).find("img").attr("src", attrObj);
		});
		$("#topAD").click(function() {
			$("#topA").toggleClass(" glyphicon-triangle-right");
			$("#topA").toggleClass(" glyphicon-triangle-bottom");
		});
		$("#topBD").click(function() {
			$("#topB").toggleClass(" glyphicon-triangle-right");
			$("#topB").toggleClass(" glyphicon-triangle-bottom");
		});
		$("#topCD").click(function() {
			$("#topC").toggleClass(" glyphicon-triangle-right");
			$("#topC").toggleClass(" glyphicon-triangle-bottom");
		});
		$(".toggle-btn").click(function() {
			$("#leftMeun").toggleClass("show");
			$("#rightContent").toggleClass("pd0px");
		})
	})
</script>
<style type="text/css">
::-webkit-scrollbar {
	display: none
}

.table {
	text-align: center;
	table-layout: fixed;
	/*word-wrap: break-word;
	overflow: hidden;*/
}

.tableHeader {
	text-align: center;
}

td {
	width: 100%;
	word-break: keep-all;
	/* 不换行 */
	white-space: nowrap;
	/* 不换行 */
	/*overflow: hidden;*/
	overflow-x: scroll;
	/* 内容超出宽度时隐藏超出部分的内容 */
	/*text-overflow: ;*/
	/* 当对象内文本溢出时显示省略标记(...) ；需与overflow:hidden;一起使用。*/
}
</style>
<script type="text/javascript">
	$(function() {
		$(".tdd").mouseover(function() {
			alert($(this).text());
		});
	});
</script>
<!--[if lt IE 9]>
  <script src="js/html5shiv.min.js"></script>
  <script src="js/respond.min.js"></script>
<![endif]-->
<!-- 引入layui.css文件 -->
<link rel="stylesheet" href="layui/css/layui.css" media="all">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/common.css" />
<link rel="stylesheet" type="text/css" href="css/slide.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="css/flat-ui.min.css" />
<link rel="stylesheet" type="text/css" href="css/jquery.nouislider.css">



<!-- 引入layui.css文件 -->
<link rel="stylesheet" href="layui/css/layui.css" media="all">

<!--1. Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">

</head>

<body>
	<div id="wrap">
		<!-- 左侧菜单栏目块 -->
		<div class="leftMeun" id="leftMeun">
			<div id="logoDiv">
				<p id="logoP">
					<img id="logo" src="images/logo3.jpg"><span>与食俱进</span>
				</p>
			</div>
			<div id="personInfor">
				<p id="userName">大洋</p>
				<p></p>
				<p>
					<a>退出登录</a>
				</p>
			</div>
			<div class="meun-title">人员管理</div>
			<div class="meun-item " href="#shop" aria-controls="shop" role="tab"
				data-toggle="tab">
				<img src="images/icon_source.png">商家管理
			</div>
			<div class="meun-item meun-item-active " href="#users"
				aria-controls="users" role="tab" data-toggle="tab">
				<img src="images/icon_chara_grey.png">用户管理
			</div>
			<div class="meun-title">营业管理</div>
			<div class="meun-item" href="#orders" aria-controls="orders"
				role="tab" data-toggle="tab">
				<img src="images/icon_house.png">订单管理
			</div>
			<div class="meun-item" href="#statistics" aria-controls="statistics"
				role="tab" data-toggle="tab">
				<img src="images/icon_source.png">营业额统计
			</div>
			<div class="meun-item" href="#comments" aria-controls="comments"
				role="tab" data-toggle="tab">
				<img src="images/icon_source.png">评价管理
			</div>
		</div>
		<!-- 右侧具体内容栏目 -->
		<div id="rightContent">
			<a class="toggle-btn" id="nimei"> <i
				class="glyphicon glyphicon-align-justify"></i>
			</a>
			<!-- Tab panes -->
			<div class="tab-content">
				<!-- 用户管理模块 -->
				<div role="tabpanel" class="tab-pane" id="users"
					style="display: block;">

					<div class="check-div form-inline">
						<div class="col-xs-8">
							<button class="btn btn-yellow btn-xs" data-toggle="modal"
								data-target="#addUsers">添加用户</button>
						</div>
						<div class="col-xs-4">
							<form class="form-horizontal" method="post" action="UsersServlet">
								<!-- 隐藏域 -->
								<input type="hidden" name="op" value="selectUsersByPage">
								<input type="text" class="form-control input-sm" id="keyword"
									name="keyword" value="${keyword}" placeholder="输入文字搜索">
								<button class="btn btn-white btn-xs ">查 询</button>
							</form>
						</div>
					</div>
					<div class="data-div">

						<table class="table table-striped table-hover table-responsive">
							<thead>
								<tr>
									<td class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">用户编号</td>
									<td class="col-lg-2 col-md-2 col-sm-2 col-xs-2 ">用户账号</td>
									<td class="col-lg-2 col-md-2 col-sm-2 col-xs-2 ">用户电话</td>
									<td class="col-lg-2 col-md-2 col-sm-2 col-xs-2 ">用户邮箱</td>
									<td class="col-lg-2 col-md-2 col-sm-2 col-xs-2 ">用户地址</td>
									<td class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">用户状态</td>
									<td class="col-lg-2 col-md-2 col-sm-2 col-xs-2 ">操作</td>
								</tr>
							</thead>
							<tbody>
								<!-- 如果属性范围内的pd为null，重定向至UsersServlet获取pd，再转发回来 -->
								<c:if test="${pd==null}">
									<c:redirect url="UsersServlet?op=selectUsersByPage"></c:redirect>
								</c:if>
								<!-- 如果属性范围内的pd不为空，遍历 ，密码不显示-->
								<c:if test="${pd!=null}">
									<c:forEach items="${pd.data}" var="users">
										<tr>
											<td class="col-lg-1 col-md-1 col-sm-1 col-xs-1">${users.userid}
											</td>
											<td class="col-lg-2 col-md-2 col-sm-2 col-xs-2">${users.username}
											</td>
											<td class="col-lg-2 col-md-2 col-sm-2 col-xs-2">${users.userphone}
											</td>
											<td class="col-lg-2 col-md-2 col-sm-2 col-xs-2">${users.useremail}
											</td>
											<td class="col-lg-2 col-md-2 col-sm-2 col-xs-2">${users.useraddress}
											</td>
											<td class="col-lg-1 col-md-1 col-sm-1 col-xs-1">${users.userstate==true?"启用":"禁用"}</td>
											<td class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
												<button class="btn btn-success btn-xs updUsers"
													data-toggle="modal" data-target="#updateUsers">修改</button>
												<button class="btn btn-danger btn-xs delUsers"
													data-toggle="modal" data-target="#deleteUsers">删除</button>
												<button class="btn btn-success btn-xs resUserspsw"
													data-toggle="modal" data-target="#resetUserspsw">重置</button>
											</td>
										</tr>
									</c:forEach>
								</c:if>
							</tbody>
						</table>
					</div>
					<!--页码块-->

					<div id="pagediv" style="text-align: center"></div>

					<!--添加用户弹出窗口-->
					<div class="modal fade" id="addUsers" role="dialog"
						aria-labelledby="gridSystemModalLabel">
						<div class="modal-dialog" role="document">
							<div class="modal-content">
								<div class="modal-header">
									<button type="button" class="close" data-dismiss="modal"
										aria-label="Close">
										<span aria-hidden="true">&times;</span>
									</button>
									<h4 class="modal-title" id="gridSystemModalLabel">添加用户</h4>
								</div>
								<form class="form-horizontal" method="post"
									action="UsersServlet" onsubmit="return check()">
									<div class="modal-body">
										<div class="container-fluid">
											<!-- 隐藏域，传递op参数 -->
											<input type="hidden" name="op" value="addUsers">
											<div class="form-group ">
												<label for="username" class="col-xs-3 control-label">用户账号：</label>
												<div class="col-xs-6 ">
													<input type="text"
														class="form-control input-sm duiqi username"
														name="username" id="username1" required="required"
														placeholder="请输入用户账号"> <span id="msg"></span>
												</div>
											</div>
											<div class="form-group">
												<label for="userpsw" class="col-xs-3 control-label">用户密码：</label>
												<div class="col-xs-6 ">
													<input type="password"
														class="form-control input-sm duiqi userpsw" name="userpsw"
														id="userpsw1" required="required" placeholder="请输入用户密码">
												</div>
											</div>
											<div class="form-group">
												<label for="conuserpsw" class="col-xs-3 control-label">确认密码：</label>
												<div class="col-xs-6 ">
													<input type="password"
														class="form-control input-sm duiqi conuserpsw"
														name="conuserpsw" id="conuserpsw1" required="required"
														placeholder="请再次输入用户密码"><span id="msg1"></span>
												</div>
											</div>
											<div class="form-group">
												<label for="userphone" class="col-xs-3 control-label">用户电话：</label>
												<div class="col-xs-6">
													<input type="text" class="form-control input-sm duiqi"
														name="userphone" required="required" pattern="[0-9]{11}"
														placeholder="请输入电话号码">
												</div>
											</div>
											<div class="form-group">
												<label for="useremail" class="col-xs-3 control-label">用户邮箱：</label>
												<div class="col-xs-6">
													<input type="email" class="form-control input-sm duiqi"
														name="useremail" required="required" placeholder="请输入电子邮箱">
												</div>
											</div>
											<div class="form-group">
												<label for="useraddress" class="col-xs-3 control-label">用户地址：</label>
												<div class="col-xs-6">
													<input type="text" class="form-control input-sm duiqi"
														name="useraddress" required="required" placeholder="请输入地址">
												</div>
											</div>

										</div>
									</div>
									<div class="modal-footer">
										<button type="button" class="btn btn-xs btn-white"
											data-dismiss="modal">取 消</button>
										<button class="btn btn-xs btn-green">保 存</button>
									</div>
								</form>
							</div>
							<!-- /.modal-content -->
						</div>
						<!-- /.modal-dialog -->
					</div>
					<!-- /.modal -->

					<!--修改用户弹出窗口-->
					<div class="modal fade" id="updateUsers" role="dialog"
						aria-labelledby="gridSystemModalLabel">
						<div class="modal-dialog" role="document">
							<div class="modal-content">
								<form class="form-horizontal" method="post"
									action="UsersServlet">
									<div class="modal-header">
										<button type="button" class="close" data-dismiss="modal"
											aria-label="Close">
											<span aria-hidden="true">&times;</span>
										</button>
										<h4 class="modal-title" id="gridSystemModalLabel">修改用户信息</h4>
									</div>
									<div class="modal-body">
										<div class="container-fluid">
											<div class="form-group ">
												<label for="userid" class="col-xs-3 control-label">用户编号：</label>
												<div class="col-xs-6 ">
													<input type="text" class="form-control input-sm duiqi"
														name="userid" id="userid" readonly="readonly">
												</div>
											</div>

											<div class="form-group ">
												<label for="username" class="col-xs-3 control-label">用户账号：</label>
												<div class="col-xs-6 ">
													<input type="text" class="form-control input-sm duiqi"
														name="username" id="username" required="required">
													<span id="msg2"></span>
												</div>
											</div>

											<div class="form-group">
												<label for="userphone" class="col-xs-3 control-label">用户电话：</label>
												<div class="col-xs-6">
													<input type="text" class="form-control input-sm duiqi"
														name="userphone" id="userphone" pattern="[0-9]{11}"
														required="required">
												</div>
											</div>
											<div class="form-group">
												<label for="useremail" class="col-xs-3 control-label">用户邮箱：</label>
												<div class="col-xs-6">
													<input type="email" class="form-control input-sm duiqi"
														name="useremail" id="useremail" required="required">
												</div>
											</div>
											<div class="form-group">
												<label for="useraddress" class="col-xs-3 control-label">用户地址：</label>
												<div class="col-xs-6">
													<input type="text" class="form-control input-sm duiqi"
														name="useraddress" id="useraddress" required="required">
												</div>
											</div>
											<div class="form-group">
												<label for="userstate" class="col-xs-3 control-label">用户状态：</label>
												<div class="col-xs-6">
													<select id="userstate" name="userstate"
														class="form-control input-sm duiqi">
														<option value="true">启用</option>
														<option value="false">禁用</option>
													</select>
												</div>
											</div>
										</div>
									</div>
									<!-- 隐藏域，传递op参数 -->
									<input type="hidden" name="op" value="updateUsers">
									<div class="modal-footer">
										<button type="button" class="btn btn-xs btn-white"
											data-dismiss="modal">取 消</button>
										<button class="btn btn-xs btn-green updConfirm">确定</button>

									</div>
								</form>
							</div>
							<!-- /.modal-content -->
						</div>
						<!-- /.modal-dialog -->
					</div>
					<!-- /.modal -->

					<!--弹出删除用户警告窗口-->
					<div class="modal fade" id="deleteUsers" role="dialog"
						aria-labelledby="gridSystemModalLabel">
						<div class="modal-dialog" role="document">
							<div class="modal-content">
								<div class="modal-header">
									<button type="button" class="close" data-dismiss="modal"
										aria-label="Close">
										<span aria-hidden="true">&times;</span>
									</button>
									<h4 class="modal-title" id="gridSystemModalLabel">提示</h4>
								</div>

								<div class="modal-body">
									<div class="container-fluid">确定要删除该用户？删除后不可恢复！</div>
								</div>
								<div class="modal-footer">
									<button type="button" class="btn btn-xs btn-white"
										data-dismiss="modal">取 消</button>
									<button type="button" class="btn btn-xs btn-danger delConfirm">确定</button>
								</div>
							</div>
							<!-- /.modal-content -->
						</div>
						<!-- /.modal-dialog -->
					</div>
					<!-- /.modal -->
				</div>

				<!--弹出重置用户密码警告窗口-->
				<div class="modal fade" id="resetUserspsw" role="dialog"
					aria-labelledby="gridSystemModalLabel">
					<div class="modal-dialog" role="document">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal"
									aria-label="Close">
									<span aria-hidden="true">&times;</span>
								</button>
								<h4 class="modal-title" id="gridSystemModalLabel">提示</h4>
							</div>

							<div class="modal-body">
								<div class="container-fluid">确定重置该用户密码？</div>
							</div>
							<div class="modal-footer">
								<button type="button" class="btn btn-xs btn-white"
									data-dismiss="modal">取 消</button>
								<button type="button" class="btn btn-xs btn-danger resConfirm">确定</button>
							</div>
						</div>
						<!-- /.modal-content -->
					</div>
					<!-- /.modal-dialog -->
				</div>
				<!-- /.modal -->
			</div>

			<!-- 滑块js -->
			<!--	<script type="text/javascript">
        scale = function(btn, bar, title, unit) {
                this.btn = document.getElementById(btn);
                this.bar = document.getElementById(bar);
                this.title = document.getElementById(title);
                this.step = this.bar.getElementsByTagName("
									div")[0];
                this.unit=unit;
									this.init();
        };
        scale.prototype={ init:
									function() {
                        var f=this, g=document,
									b=window, m=Math; f.btn.onmousedown=function(e)
									{
                                var x=(e
									|| b.event).clientX;
                                var
									l=this.offsetLeft; //						var max=f.bar.offsetWidth
									- this.offsetWidth;
                                var
									max=f.bar.offsetWidth-20
									;
                                g.onmousemove=function(e)
									{
                                        var thisX=(e
									|| b.event).clientX;
                                        var
									to=m.min(max,
									m.max(-2, l + (thisX - x)));
                                        f.btn.style.left=to+
									'px';
                                        f.ondrag(m.round(m.max(0, to / max)
									* 100), to);
                                        b.getSelection ? b.getSelection().removeAllRanges()
									:
									g.selection.empty();
                                };
                                g.onmouseup=new
									Function('this.onmousemove=null
									');
                        };
                },
                ondrag:
									function(pos, x) {
                        this.step.style.width=Math.max(0,
									x) +2+ 'px';
                        this.title.innerHTML=pos
									/ 10 + this.unit + "";
                }
        }
        new
									scale('btn0', 'bar0', 'title0', "分钟");
        new
									scale('btn1', 'bar1', 'title1', "分钟");
        new
									scale('btn2', 'bar2', 'title2', "天");
        newscale('btn3', 'bar3', 'title3', "次");

									</script>
-->
			<script src="js/jquery.nouislider.js"></script>

			<!-- 引入layui.js文件 -->
			<script src="${pageContext.request.contextPath}/layui/layui.js"
				charset="utf-8"></script>

			<!-- this page specific inline scripts -->
			<script>
		//min/max slider
		function huadong(my, unit, def, max) {
			$(my).noUiSlider(
					{
						range : [ 0, max ],
						start : [ def ],
						handles : 1,
						connect : 'upper',
						slide : function() {
							var val = Math.floor($(this).val());
							$(this).find(".noUi-handle").text(val + unit);
							console.log($(this).find(".noUi-handle").parent()
									.parent().html());
						},
						set : function() {
							var val = Math.floor($(this).val());
							$(this).find(".noUi-handle").text(val + unit);
						}
					});
			$(my).val(def, true);
		}
		huadong('.slider-minmax1', "分钟", "5", 30);
		huadong('.slider-minmax2', "分钟", "6", 15);
		huadong('.slider-minmax3', "分钟", "10", 60);
		huadong('.slider-minmax4', "次", "2", 10);
		huadong('.slider-minmax5', "天", "3", 7);
		huadong('.slider-minmax6', "天", "8", 10);
	</script>
			<script>
	/* ************分页的开始***************** */
	layui.use(['laypage', 'layer'], function(){
		  var laypage = layui.laypage
		  ,layer = layui.layer;
		  
		//完整功能
		  laypage.render({
		    elem: 'pagediv'
		    ,theme:'#7D9EC0'
		    ,count: ${pd.totalCount}
		    ,curr: ${pd.page}
		    ,limit: ${pd.pageSize}
		    ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
		    ,jump: function(obj, first){
			    //obj包含了当前分页的所有参数，比如：
			    console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
			    console.log(obj.limit); //得到每页显示的条数
			    
			    //首次不执行
			    //分页的时候也要把查询的关键字传到servlet
			    if(!first){
			      //do something
			       location.href="UsersServlet?op=selectUsersByPage&page="+obj.curr+"&pageSize="+obj.limit+"&keyword="+$("#keyword").val();
			    }
			  }
		  });
		 
		}); 
	/* ************分页的结束***************** */
	
	/* ************删除的开始***************** */
	var userid=0;
	//删除用户
	$(".delUsers").click(function(){
		//获取到userid,也就是表格的当前第一列
		userid = $(this).parents("tr").find("td").eq(0).text();
		console.log("userid:"+userid)
	});
	$(".delConfirm").click(function(){
		$.ajax({
			url:"UsersServlet",
			type:"post",
			data:{
				userid:userid,
				op:"deleteUsers"
				
			},
		success:function(res){
			if(res.msg=="true"){
				console.log("true")
				location.href="UsersServlet?op=selectUsersByPage&page="+${pd.page}+"&pageSize="+${pd.pageSize}+"&keyword="+$("#keyword").val();
			}else{
				console.log("false")
				layer.msg('删除失败',{
					icon:1,
				time:2000,
				btn:['确定']
				});
			}
		},
		datatype:"json"
		});
	});
	/* ************删除的结束***************** */
	
	/* ************修改的开始***************** */
	
		var userid=0;
		var username=null;
		var userphone=null;
		var useremail=null;
		var useraddress=null;
		var userstate=true;
	$(".updUsers").click(function(){
		//得到当前选中行的用户信息
		userid=$(this).parents("tr").find("td").eq(0).text();
		username=$(this).parents("tr").find("td").eq(1).text();
		userphone=$(this).parents("tr").find("td").eq(2).text();
		useremail=$(this).parents("tr").find("td").eq(3).text();
		useraddress=$(this).parents("tr").find("td").eq(4).text();
		userstate=$(this).parents("tr").find("td").eq(5).text();
		//将得到的信息显示在修改用户信息的对应文本框里
		$("#userid").val(userid);
		$("#username").val(username);
		$("#userphone").val(userphone);
		$("#useremail").val(useremail);
		$("#useraddress").val(useraddress);
		//如果userstate为启用
		if(userstate=="启用"){
			//选中id为userstate的 下拉列表的true“启用”
			$("#userstate").val("true");
		}else if(userstate=="禁用"){
			$("#userstate").val("false");
		}	
	});	
	/* ************修改的结束***************** */
	/* ************重置密码的开始***************** */
	var userid=0;
	//重置用户
	$(".resUserspsw").click(function(){
		//获取到userid,也就是表格的当前第一列
		userid = $(this).parents("tr").find("td").eq(0).text();
		console.log("userid:"+userid)
	});
	$(".resConfirm").click(function(){
		$.ajax({
			url:"UsersServlet",
			type:"post",
			data:{
				userid:userid,
				op:"resetUserspsw"	
			},
		success:function(res){
			if(res.msg=="true"){
				console.log("true")
				location.href="UsersServlet?op=selectUsersByPage&page="+${pd.page}+"&pageSize="+${pd.pageSize}+"&keyword="+$("#keyword").val();
			}else{
				console.log("false")
				layer.msg('重置失败',{
					icon:1,
				time:2000,
				btn:['确定']
				});
			}
		},
		datatype:"json"
		});
	});
	/* ************重置密码的结束***************** */
	
	/* ************检测管理员添加用户时输入的用户名是否已被使用***************** */
	//标记一下ajaxName函数是否有执行
	var msg = "";
	$(function() {
		//文本框事件，失去焦点
		$("#username1").blur(
				function() {
					//1验证用户输入的是否是空格
					if ($("#username1").val() != ""
							|| $("#username1").val().indexOf(" ") > 0) {
						//2保证输入的不是空格再调用ajaxName
						ajaxName();
					}
				});
	});
	function ajaxName() {
		$.ajax({
			//key:value
			url : "UsersServlet",
			type : "get",
			data : {
				//逗号隔开
				username : $("#username1").val(),
				op : "ajaxUsername"
			},
			success : function(data) {
				msg = data;
				if (data.msg == "notexists") {
					//得到页面上id为msg的span，并为其中添加内容
					$("#msg").html("该用户名可以使用。");
				} else {
					$("#msg").html("该用户名已被使用，请更换！");
				}
			},
			dataType : "json"
		});
	}
	
	//检测用户两次输入的密码是否一致 
	//标记一下ajaxPsw函数是否有执行
	$(function() {
		//文本框事件，当密码输入框失去焦点时
		$("#userpsw1").blur(function() {
			//1检测用户是否输入了确认密码，输入过确认密码才进行判断
			if ($("#conuserpsw1").val() != "") {
				//如果两次输入密码一致
				if ($("#userpsw1").val() == $("#conuserpsw1").val()) {
					$("#msg1").html("两次密码输入一致。");
				} else {
					$("#msg1").html("两次密码输入不一致。");
				}
			}
		});
		//文本框事件，当确认密码输入框失去焦点时
		$("#conuserpsw1").blur(function() {
			//1检测用户是否输入了密码，用户输入过了密码才进行判断
			if ($("#userpsw1").val() != "") {
				if ($("#conuserpsw1").val() == $("#userpsw1").val()) {
					$("#msg1").html("两次密码输入一致。");
				} else {
					$("#msg1").html("两次密码输入不一致。");
				}
			}
		});
	});
	
	//点击添加按钮的时候，判断是否有重复的内容(用户名重复)、两次密码是如是否一致
	//校验和判断
	function check() {
		var msg = $("#msg").text();
		console.log("提交验证data->msg:" + msg);
		//当用户名未被使用，且两次密码输入一致时表单才能提交
		if (msg != "该用户名可以使用。") {
			alert('该用户名已被使用，请重新输入');
			return false;//表单不提交
		} else if ($("#userpsw1").val() != $("#conuserpsw1").val()) {
			alert('两次密码不一致，请重新输入');
			return false;//表单不提交
		} else {
			return true;
		}
	}
	
	
	</script>
</body>

</html>